package com.lx.controller;

import com.lx.serv.impl.AdminServImpl;
import com.lx.utill.JwtUtill;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping(value = "/GetImg")
public class EnsureUserController {
    @Autowired
    AdminServImpl adminServImpl;

    @GetMapping
    public Result EnsureUser(@RequestHeader("token") String token) {
//        System.out.println(token + "=======================================================");
        if (!JwtUtill.VerifyToken(token) || token == null) {
            return new Result(Code.GET_FAIL, "Token失效", null);
        }
        String adminName = adminServImpl.getNameBytoken(token);
        if (adminName.equals("root")) {
            return new Result(Code.GET_SUCCESS, "Token有效 root", "http://47.108.248.93/Img/root.png");
        }
        return new Result(Code.GET_SUCCESS, "Token有效 admin", "http://47.108.248.93/Img/admin.png");
    }
}
